package com.cloud.controller;

import com.cloud.service.DemoTableStudentService;
import com.cloud.dto.DemoTableStudentDto;
import com.cloud.model.DemoTableStudent;
import com.cloud.dto.RequestDto;
import com.cloud.dto.ResponseDto;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;

/**
 * Created by util on 2018-4-27.
 */
@Api(description = "demotablestudent相关api")
@RestController
@RequestMapping("/demotablestudent")
public class DemoTableStudentController {

    @Autowired
    private DemoTableStudentService demoTableStudentService;

    @PostMapping("/selectDemoTableStudentList")
    @ApiOperation(value = "获取demoTableStudent列表")
    public ResponseDto<List<DemoTableStudent>> selectDemoTableStudentList(@RequestBody RequestDto<DemoTableStudentDto> requestDto){
        List<DemoTableStudent> demoTableStudentList = demoTableStudentService.selectDemoTableStudentList(requestDto.getModel());
        return ResponseDto.successWithData(demoTableStudentList);
    }
    
    @PostMapping("/selectDemoTableStudentPage")
    @ApiOperation(value = "获取demoTableStudent分页列表")
    public ResponseDto<PageInfo<DemoTableStudent>> selectDemoTableStudentPage(@RequestBody RequestDto<DemoTableStudentDto> requestDto){
        PageInfo pageInfo = demoTableStudentService.selectDemoTableStudentPage(requestDto.getModel());
        return ResponseDto.successWithData(pageInfo);
    }

    @PostMapping("/selectDemoTableStudentById")
    @ApiOperation(value = "通过id获取demoTableStudent")
    public ResponseDto<DemoTableStudent> selectDemoTableStudentById(@RequestBody RequestDto<DemoTableStudentDto> requestDto){
        DemoTableStudent demoTableStudent = demoTableStudentService.selectDemoTableStudentById(requestDto.getModel());
        return ResponseDto.successWithData(demoTableStudent);
    }

    @PostMapping("/insertDemoTableStudent")
    @ApiOperation(value = "通过demoTableStudent新增")
    public ResponseDto<Boolean> insertDemoTableStudent(@RequestBody RequestDto<DemoTableStudentDto> requestDto){
        boolean flag = demoTableStudentService.insertDemoTableStudent(requestDto.getModel());
        return ResponseDto.successWithData(flag);
    }

    @PostMapping("/updateDemoTableStudent")
    @ApiOperation(value = "通过demoTableStudent更新")
    public ResponseDto<Boolean> updateDemoTableStudent(@RequestBody RequestDto<DemoTableStudentDto> requestDto){
        boolean flag = demoTableStudentService.updateDemoTableStudent(requestDto.getModel());
        return ResponseDto.successWithData(flag);
    }

    @PostMapping("/deleteDemoTableStudent")
    @ApiOperation(value = "通过demoTableStudent删除")
    public ResponseDto<Boolean> deleteDemoTableStudent(@RequestBody RequestDto<DemoTableStudentDto> requestDto){
        boolean flag = demoTableStudentService.deleteDemoTableStudent(requestDto.getModel());
        return ResponseDto.successWithData(flag);
    }
    
}
